﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Pku.BookStore.Web.Controllers
{
    public class BaseController : Controller
    {
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var strControllerName = filterContext.Controller.ToString();
            var strActionName = filterContext.RouteData.Values.Values.ToList()[1].ToString();
            if (strControllerName.Contains("AdminController"))
            {
                if (strActionName != "LogOn")
                {
                    if (Session["EmployeeID"] == null)
                    {
                        filterContext.Result = new RedirectResult("/Admin/LogOn");
                    }
                }
            }
        }
    }
}
